//
//  HomeBtnView.swift
//  BQWB
//
//  Created by laibingqiang on 16/10/27.
//  Copyright © 2016年 laibingqiang. All rights reserved.
//

import UIKit

class HomeBtnView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    var model:HomeStatusViewModel?{
        
        didSet{
            
            retweetBtn.setTitle(model?.reposts_count, for: UIControlState.normal)
            
            commentBtn.setTitle(model?.comments_count, for: UIControlState.normal)
            
            likeBtn.setTitle(model?.attitudes_count, for: UIControlState.normal)
            
        }
    }
    //监听方法
    @objc private func commentClink(){
    
    }
    
    @objc private func retweetClink(){
        
    }
    @objc private func likeClink(){
        
    }
    
    private func setupUI(){
        addSubview(retweetBtn)
        addSubview(commentBtn)
        addSubview(likeBtn)
        addSubview(lineV1)
        addSubview(lineV2)
        
        retweetBtn.snp_makeConstraints { (make) in
            
            make.top.left.bottom.equalTo(self)
            
            make.width.equalTo(commentBtn)
        }
        
        commentBtn.snp_makeConstraints { (make) in
            
            make.top.bottom.equalTo(self)
            
            make.left.equalTo(retweetBtn.snp_right)
            
            make.width.equalTo(likeBtn)
        }
        
        likeBtn.snp_makeConstraints { (make) in
            
            make.top.bottom.right.equalTo(self)
            
            make.left.equalTo(commentBtn.snp_right)
            
        }
        
        lineV1.snp_makeConstraints { (make) in
            
            make.centerY.equalTo(self)
            make.centerX.equalTo(retweetBtn.snp_right)
        }
        
        lineV2.snp_makeConstraints { (make) in
            
            make.centerY.equalTo(self)
            make.centerX.equalTo(commentBtn.snp_right)
        }
        
    }
    //懒加载
    //转发
    private lazy var retweetBtn:UIButton = {
        
        let btn = UIButton(target: self, action: #selector(retweetClink), imgName: "timeline_icon_retweet", backImg: "timeline_card_bottom_background", title: "转发")
        
        return btn
        
    }()
    //评论
    private lazy var commentBtn:UIButton = {
        
        let btn = UIButton(target: self, action: #selector(commentClink), imgName: "timeline_icon_comment", backImg: "timeline_card_bottom_background", title: "评论")
        
        return btn
    }()
    //点赞
    private lazy var likeBtn:UIButton = {
        
        let btn = UIButton(target: self, action: #selector(likeClink), imgName: "timeline_icon_unlike", backImg: "timeline_card_bottom_background", title: "赞")
        
        return btn
        
    }()
    //分割线
    private lazy var lineV1:UIImageView = UIImageView(imgName: "timeline_card_bottom_line")
    
    private lazy var lineV2:UIImageView = UIImageView(imgName: "timeline_card_bottom_line")
    
    
}
